package Java.BlackHorse.a05IOTest;

import java.io.*;
import java.util.Arrays;

public class Test4 {
    public static void main(String[] args) throws IOException {
        FileReader fis = new FileReader("a05IOTest\\a.txt");
        StringBuilder sb = new StringBuilder();
        int ch;
        while((ch= fis.read()) != -1){
            sb.append((char)ch);
        }
        fis.close();
        System.out.println(sb);
        Integer[] arr = Arrays.stream(sb.toString().split("-")).
                map(Integer::parseInt).
                sorted().
                toArray(Integer[]::new);
        System.out.println(Arrays.toString(arr));
        FileWriter fos = new FileWriter("a05IOTest\\a.txt");
        String s = new String(Arrays.toString(arr)).replace(", ","-");
        String res = s.substring(1,s.length()-1);
        System.out.println(res);
        fos.write(res);
        fos.close();
    }
}
